/*     */ package eos.moe.dragoncore.renderer;
/*     */ 
/*     */ import com.google.gson.ExclusionStrategy;
/*     */ import com.google.gson.FieldAttributes;
/*     */ import com.google.gson.Gson;
/*     */ import com.google.gson.GsonBuilder;
/*     */ import eos.moe.dragoncore.data.SignData;
/*     */ import eos.moe.dragoncore.gp;
/*     */ import eos.moe.dragoncore.ld;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import net.minecraft.client.Minecraft;
/*     */ import net.minecraft.client.gui.FontRenderer;
/*     */ import net.minecraft.client.renderer.BufferBuilder;
/*     */ import net.minecraft.client.renderer.GlStateManager;
/*     */ import net.minecraft.client.renderer.RenderHelper;
/*     */ import net.minecraft.client.renderer.Tessellator;
/*     */ import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
/*     */ import net.minecraft.client.renderer.texture.TextureManager;
/*     */ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
/*     */ import net.minecraft.item.ItemStack;
/*     */ import net.minecraft.nbt.JsonToNBT;
/*     */ import net.minecraft.nbt.NBTException;
/*     */ import net.minecraft.nbt.NBTTagCompound;
/*     */ import net.minecraft.tileentity.TileEntitySign;
/*     */ import net.minecraft.util.ResourceLocation;
/*     */ import net.minecraft.util.math.BlockPos;
/*     */ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/*     */ 
/*     */ public class SignRenderer
/*     */ {
/*  32 */   public static Map<String, SignData> signDataMap = new HashMap<>();
/*  33 */   public static final Gson gson = (new GsonBuilder()).setExclusionStrategies(new ExclusionStrategy[] { new ExclusionStrategy()
/*     */         {
/*     */           public boolean shouldSkipField(FieldAttributes fieldAttributes) {
/*  36 */             return false;
/*     */           }
/*     */ 
/*     */ 
/*     */           
/*     */           public boolean shouldSkipClass(Class<ItemStack> clazz) {
/*  42 */             return (clazz == ItemStack.class);
/*     */           }
/*  44 */         } }).create();
/*  45 */   protected static final ResourceLocation[] DESTROY_STAGES = new ResourceLocation[] { new ResourceLocation("textures/blocks/destroy_stage_0.png"), new ResourceLocation("textures/blocks/destroy_stage_1.png"), new ResourceLocation("textures/blocks/destroy_stage_2.png"), new ResourceLocation("textures/blocks/destroy_stage_3.png"), new ResourceLocation("textures/blocks/destroy_stage_4.png"), new ResourceLocation("textures/blocks/destroy_stage_5.png"), new ResourceLocation("textures/blocks/destroy_stage_6.png"), new ResourceLocation("textures/blocks/destroy_stage_7.png"), new ResourceLocation("textures/blocks/destroy_stage_8.png"), new ResourceLocation("textures/blocks/destroy_stage_9.png") };
/*     */ 
/*     */   
/*     */   public static SignData getSignData(String a) {
/*  49 */     if (signDataMap.containsKey(a)) {
/*  50 */       return signDataMap.get(a);
/*     */     }
/*     */     
/*     */     try {
/*  54 */       String str = a.substring(0, a.length() - 2);
/*  55 */       SignData signData = (SignData)gson.fromJson(str, SignData.class);
/*  56 */       signDataMap.put(a, signData);
/*  57 */       return signData;
/*  58 */     } catch (Exception exception) {
/*  59 */       signDataMap.put(a, null);
/*  60 */       return null;
/*     */     } 
/*     */   }
/*     */   
/*     */   public static float distance(double a, double d1, double d2) {
/*  65 */     return (float)Math.sqrt(square(a) + square(d1) + square(d2));
/*     */   }
/*     */   
/*     */   public static double square(double a) {
/*  69 */     return a * a;
/*     */   }
/*     */   
/*     */   public static void render(FontRenderer a, TileEntitySign tileEntitySign, double d1, double d2, double d3, float f1, int i, float f2, CallbackInfo callbackInfo) {
/*  73 */     if (tileEntitySign.field_145915_a.length <= 1)
/*     */       return; 
/*  75 */     if (tileEntitySign.field_145915_a[1] == null) {
/*     */       return;
/*     */     }
/*  78 */     String str1 = tileEntitySign.field_145915_a[1].func_150254_d();
/*  79 */     SignData signData = getSignData(str1);
/*  80 */     if (signData == null) {
/*     */       return;
/*     */     }
/*  83 */     if (signData.getModel() == null || signData.getCheck() == null) {
/*     */       return;
/*     */     }
/*  86 */     if (!signData.getCheck().contains("§")) {
/*     */       return;
/*     */     }
/*     */ 
/*     */     
/*  91 */     callbackInfo.cancel();
/*  92 */     int j = tileEntitySign.func_145832_p();
/*  93 */     float f3 = 0.0F;
/*  94 */     if (j == 2) {
/*  95 */       f3 = 180.0F;
/*     */     }
/*     */     
/*  98 */     if (j == 4) {
/*  99 */       f3 = 90.0F;
/*     */     }
/*     */     
/* 102 */     if (j == 5) {
/* 103 */       f3 = -90.0F;
/*     */     }
/* 105 */     String str2 = signData.getModel();
/*     */     
/* 107 */     BlockPos blockPos = tileEntitySign.func_174877_v();
/* 108 */     ld ld = gp.v(str2);
/* 109 */     gp.v(blockPos.func_177958_n(), blockPos.func_177956_o(), blockPos.func_177952_p(), str2, ld, "idle");
/*     */     
/* 111 */     GlStateManager.func_179126_j();
/* 112 */     GlStateManager.func_179143_c(515);
/* 113 */     GlStateManager.func_179132_a(true);
/* 114 */     GlStateManager.func_179129_p();
/* 115 */     if (i >= 0) {
/* 116 */       bindTexture(DESTROY_STAGES[i]);
/* 117 */       GlStateManager.func_179128_n(5890);
/* 118 */       GlStateManager.func_179094_E();
/* 119 */       GlStateManager.func_179152_a(4.0F, 4.0F, 1.0F);
/* 120 */       GlStateManager.func_179109_b(0.0625F, 0.0625F, 0.0625F);
/* 121 */       GlStateManager.func_179128_n(5888);
/*     */     } else {
/* 123 */       gp.v(str2);
/*     */     } 
/* 125 */     GlStateManager.func_179094_E();
/* 126 */     GlStateManager.func_179091_B();
/* 127 */     if (i < 0) {
/* 128 */       GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, f2);
/*     */     }
/*     */ 
/*     */     
/* 132 */     GlStateManager.func_179094_E();
/* 133 */     GlStateManager.func_179137_b(d1, d2, d3);
/* 134 */     GlStateManager.func_179109_b(0.5F, 0.0F, 0.5F);
/* 135 */     GlStateManager.func_179114_b(-f3, 0.0F, 1.0F, 0.0F);
/* 136 */     GlStateManager.func_179109_b(0.0F, 0.0F, -1.0F);
/*     */     
/* 138 */     GlStateManager.func_179152_a(1.0F, -1.0F, -1.0F);
/* 139 */     ld.render(0.0625F);
/* 140 */     ld.clearData();
/* 141 */     GlStateManager.func_179121_F();
/*     */ 
/*     */ 
/*     */     
/* 145 */     if (distance(d1, d2, d3) < 15.0F) {
/*     */ 
/*     */       
/* 148 */       GlStateManager.func_179109_b((float)d1 + 0.5F, (float)d2 + 1.5F, (float)d3 + 0.5F);
/*     */ 
/*     */       
/* 151 */       GlStateManager.func_179089_o();
/* 152 */       GlStateManager.func_179101_C();
/*     */       
/* 154 */       GlStateManager.func_179094_E();
/* 155 */       GlStateManager.func_179140_f();
/* 156 */       GlStateManager.func_179152_a(0.75F, 0.75F, 0.75F);
/* 157 */       GlStateManager.func_179114_b(-f3, 0.0F, 1.0F, 0.0F);
/* 158 */       GlStateManager.func_179109_b(0.0F, 0.0F, -1.45F);
/* 159 */       GlStateManager.func_179137_b(0.0D, signData.getOffsetY(), 0.0D);
/*     */ 
/*     */       
/* 162 */       GlStateManager.func_179123_a();
/* 163 */       GlStateManager.func_179114_b(-35.0F, 1.0F, 0.0F, 0.0F);
/*     */       
/* 165 */       RenderHelper.func_74519_b();
/*     */ 
/*     */       
/*     */       try {
/* 169 */         NBTTagCompound nBTTagCompound = JsonToNBT.func_180713_a(signData.getItem());
/* 170 */         ItemStack itemStack = null;
/* 171 */         if (signData.getItemStack() != null) {
/* 172 */           itemStack = signData.getItemStack();
/*     */         } else {
/* 174 */           itemStack = new ItemStack(nBTTagCompound);
/* 175 */           signData.setItemStack(itemStack);
/*     */         } 
/*     */         
/* 178 */         Minecraft.func_71410_x().func_175599_af().func_181564_a(itemStack, ItemCameraTransforms.TransformType.FIXED);
/* 179 */       } catch (NBTException nBTException) {}
/*     */ 
/*     */ 
/*     */ 
/*     */       
/* 184 */       RenderHelper.func_74518_a();
/* 185 */       GlStateManager.func_179099_b();
/* 186 */       GlStateManager.func_179121_F();
/*     */ 
/*     */ 
/*     */ 
/*     */       
/* 191 */       GlStateManager.func_179152_a(1.0F, -1.0F, -1.0F);
/* 192 */       GlStateManager.func_179091_B();
/* 193 */       GlStateManager.func_179094_E();
/*     */       
/* 195 */       GlStateManager.func_179147_l();
/* 196 */       GlStateManager.func_187428_a(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
/*     */ 
/*     */       
/* 199 */       GlStateManager.func_179114_b(-f3, 0.0F, 1.0F, 0.0F);
/* 200 */       if (j == 3 || j == 2) {
/* 201 */         GlStateManager.func_179109_b(0.0F, 0.0F, 0.45F);
/*     */       } else {
/* 203 */         GlStateManager.func_179109_b(0.0F, 0.0F, -0.45F);
/*     */       } 
/* 205 */       GlStateManager.func_179114_b(-f3, 0.0F, -1.0F, 0.0F);
/* 206 */       GlStateManager.func_179137_b(0.0D, -signData.getOffsetY(), 0.0D);
/*     */       
/* 208 */       float f5 = (Minecraft.func_71410_x().func_175598_ae()).field_78735_i;
/* 209 */       float f6 = (Minecraft.func_71410_x().func_175598_ae()).field_78732_j;
/* 210 */       GlStateManager.func_179114_b(f5, 0.0F, 1.0F, 0.0F);
/* 211 */       GlStateManager.func_179114_b(f6, 1.0F, 0.0F, 0.0F);
/* 212 */       GlStateManager.func_179114_b(180.0F, 0.0F, 1.0F, 0.0F);
/* 213 */       GlStateManager.func_179139_a(0.015D, 0.015D, 0.015D);
/*     */ 
/*     */       
/* 216 */       int k = 0;
/* 217 */       int m = signData.getInfo().size() * 10;
/* 218 */       for (String str : signData.getInfo()) {
/* 219 */         k = Math.max(a.func_78256_a(str), k);
/*     */       }
/*     */       
/* 222 */       float f7 = k / 2.0F;
/* 223 */       float f8 = m / 2.0F;
/*     */       
/* 225 */       GlStateManager.func_179132_a(false);
/* 226 */       GlStateManager.func_179090_x();
/* 227 */       Tessellator tessellator = Tessellator.func_178181_a();
/* 228 */       BufferBuilder bufferBuilder = tessellator.func_178180_c();
/*     */       
/* 230 */       bufferBuilder.func_181668_a(7, DefaultVertexFormats.field_181706_f);
/* 231 */       bufferBuilder.func_181662_b(-f7, (-f8 - 1.0F), 0.001D).func_181669_b(signData.getColorR(), signData.getColorG(), signData.getColorB(), signData.getColorA()).func_181675_d();
/* 232 */       bufferBuilder.func_181662_b(-f7, (f8 - 1.0F), 0.001D).func_181669_b(signData.getColorR(), signData.getColorG(), signData.getColorB(), signData.getColorA()).func_181675_d();
/* 233 */       bufferBuilder.func_181662_b(f7, (f8 - 1.0F), 0.001D).func_181669_b(signData.getColorR(), signData.getColorG(), signData.getColorB(), signData.getColorA()).func_181675_d();
/* 234 */       bufferBuilder.func_181662_b(f7, (-f8 - 1.0F), 0.001D).func_181669_b(signData.getColorR(), signData.getColorG(), signData.getColorB(), signData.getColorA()).func_181675_d();
/*     */       
/* 236 */       tessellator.func_78381_a();
/* 237 */       GlStateManager.func_179098_w();
/* 238 */       for (int n = 0; n < signData.getInfo().size(); n++) {
/* 239 */         String str = signData.getInfo().get(n);
/* 240 */         int i1 = a.func_78256_a(str);
/* 241 */         a.func_78276_b(str, -i1 / 2, (int)(-f8 + (n * 10)), -1);
/*     */       } 
/*     */ 
/*     */       
/* 245 */       GlStateManager.func_179132_a(true);
/* 246 */       GlStateManager.func_179084_k();
/* 247 */       GlStateManager.func_179126_j();
/* 248 */       GlStateManager.func_179145_e();
/* 249 */       GlStateManager.func_179121_F();
/*     */     } 
/*     */     
/* 252 */     GlStateManager.func_179121_F();
/* 253 */     float f4 = 1.0F;
/* 254 */     GlStateManager.func_179131_c(f4, f4, f4, f4);
/* 255 */     if (i >= 0) {
/* 256 */       GlStateManager.func_179128_n(5890);
/* 257 */       GlStateManager.func_179121_F();
/* 258 */       GlStateManager.func_179128_n(5888);
/*     */     } 
/*     */   }
/*     */   
/*     */   protected static void bindTexture(ResourceLocation a) {
/* 263 */     TextureManager textureManager = Minecraft.func_71410_x().func_110434_K();
/* 264 */     if (textureManager != null)
/* 265 */       textureManager.func_110577_a(a); 
/*     */   }
/*     */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\eos\moe\dragoncore\renderer\SignRenderer.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */